package com.huayi.website.service.impl;

import com.huayi.website.entity.NewsCategoryEntity;
import com.huayi.website.entity.NewsEntity;
import com.huayi.website.repository.NewsRepository;
import com.huayi.website.service.NewsService;
import com.huayi.website.utils.PagingResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsRepository repository;
    @Override
    public List<NewsCategoryEntity> getAllCategory() {
        return repository.getAllCategory();
    }

    @Override
    public NewsCategoryEntity getCategoryById(Integer id) {
        return repository.getCategoryById(id);
    }

    @Override
    public Integer editCategory(Integer categoryId, String name, String content, Integer sort, String image) {
        return repository.editCategory(categoryId,name,content,sort,image);
    }

    @Override
    public void deleteCategory(Integer id) {
        repository.deleteCategory(id);
    }

    @Override
    public void deleteNews(Integer id) {
        repository.deleteNews(id);
    }

    @Override
    public Integer editNews(NewsEntity news) {
        return repository.editNews(news);
    }

    @Override
    public PagingResponse<NewsEntity> getAllList(int pageIndex, int pageSize, String title, Integer categoryId,Integer language) {
        return repository.getAllList(pageIndex,pageSize,title,categoryId,language);
    }

    @Override
    public NewsEntity getNewsById(Integer id) {
        return repository.getNewsById(id);
    }

}
